class Solution
{
public:
    string multiply(string num1, string num2)
    {
        if (num1 == "0" || num2 == "0")
        {
            return "0";
        }
        reverse(num1.begin(), num1.end());
        reverse(num2.begin(), num2.end());
        for (auto &c : num1)
        {
            c -= '0';
        }
        for (auto &c : num2)
        {
            c -= '0';
        }
        int l1 = num1.size();
        int l2 = num2.size();
        string result(l1 + l2, '\0');
        for (int i = 0; i < l1; ++i)
        {
            for (int j = 0; j < l2; ++j)
            {
                result[i + j] += num1[i] * num2[j];
                result[i + j + 1] += result[i + j] / 10;
                result[i + j] %= 10;
            }
        }
        for (auto &c : result)
        {
            c += '0';
        }
        if (result[l1 + l2 - 1] == '0')
        {
            result.pop_back();
        }
        reverse(result.begin(), result.end());
        return result;
    }
};